package com.finalx.MyAppOnBoot;

import java.io.IOException;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class MyReceiver extends BroadcastReceiver {
	public boolean mLogRunning = false;
	public boolean mMin_free_kbytesChanged = false;
	
	public final static String mScriptLocation = "/sdcard/log_recorder.sh";
	
	private final static String TAG = "MyAppOnBoot.MyReceiver";

	@Override
	public void onReceive(Context arg0, Intent arg1) {
		
		String receivedAct = arg1.getAction();
		
		if (receivedAct.equals(Intent.ACTION_MEDIA_MOUNTED)) {
			Log.d(TAG, "media_mounted onReceive() +++");
			
			doSth();
			
			Log.d(TAG, "media_mounted onReceive() ---");
		}
	}
	
	public static void doSth() {
		
		Log.d(TAG, "doSth() ++");
		try {
			Runtime.getRuntime().exec("/system/bin/sh " + mScriptLocation);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		Log.d(TAG, "doSth() --");
	}
	

}
